package com.dm.cloud.auth.mapper;

import com.dm.cloud.auth.common.dto.AuthRoleDTO;
import com.dm.cloud.tkmybatis.service.BaseMapper;
import com.dm.cloud.auth.common.po.AuthRole;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
   * @author hcx
   * @type AuthRoleMapper.java
   * @desc AuthRole mapper
   */

@Mapper
public interface AuthRoleMapper extends BaseMapper<AuthRole> {

    @Select("select * from T_AUTH_ROLE where id in (select ROLE_ID from t_auth_user_role where USER_ID=#{uid})")
    List<AuthRole> findRoleByUid(@Param("uid") String uid);

    @Select("select * from T_AUTH_ROLE where id in " +
            " (select ROLE_ID from t_auth_user_role where USER_ID in " +
            " (select id from t_auth_user where USER_NAME=#{username} )" +
            " )")
    List<AuthRoleDTO> findRoleByUsername(String username);
}
